<?php

namespace App\Http\Controllers;

use App\Lib\LibUtil;
use App\Services\CategoryService;
use App\Services\ChinaService;
use Illuminate\Http\Request;

use App\Http\Requests;

class DemoController extends Controller
{
    public function index()
    {
        $data = ChinaService::getInstance()->getList();
//        $result = LibUtil::getInstance()->get_tree_children($data->toArray(), 130000);
//        $result = LibUtil::getInstance()->get_tree_parent($data->toArray(), 230722);
//        $result = LibUtil::getInstance()->generateTree($data->toArray());
        $items = array(
            1 => array('id' => 1, 'pid' => 0, 'name' => '安徽省'),
            2 => array('id' => 2, 'pid' => 0, 'name' => '浙江省'),
            3 => array('id' => 3, 'pid' => 1, 'name' => '合肥市'),
            4 => array('id' => 4, 'pid' => 3, 'name' => '长丰县'),
            5 => array('id' => 5, 'pid' => 1, 'name' => '安庆市'),
            6 => array('id' => 6, 'pid' => 1, 'name' => '安庆市1'),
        );
        $result = LibUtil::getInstance()->generateTree($items);
        dd($result);
    }
}
